package com.spsy.prod.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spsy.common.log.annotation.Log;
import com.spsy.common.log.enums.BusinessType;
import com.spsy.common.security.annotation.RequiresPermissions;
import com.spsy.prod.domain.TbOrderRecord;
import com.spsy.prod.service.ITbOrderRecordService;
import com.spsy.common.core.web.controller.BaseController;
import com.spsy.common.core.web.domain.AjaxResult;
import com.spsy.common.core.utils.poi.ExcelUtil;
import com.spsy.common.core.web.page.TableDataInfo;

/**
 * 订单记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-31
 */
@RestController
@RequestMapping("/prod")
public class TbOrderRecordController extends BaseController
{
    @Autowired
    private ITbOrderRecordService tbOrderRecordService;

    /**
     * 查询订单记录列表
     */
    @RequiresPermissions("prod:orderRecord:list")
    @GetMapping("/orderRecord/list")
    public TableDataInfo list(TbOrderRecord tbOrderRecord)
    {
        startPage();
        List<TbOrderRecord> list = tbOrderRecordService.selectTbOrderRecordList(tbOrderRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单记录列表
     */
    @RequiresPermissions("prod:orderRecord:export")
    @Log(title = "订单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/orderRecord/export")
    public void export(HttpServletResponse response, TbOrderRecord tbOrderRecord)
    {
        List<TbOrderRecord> list = tbOrderRecordService.selectTbOrderRecordList(tbOrderRecord);
        ExcelUtil<TbOrderRecord> util = new ExcelUtil<TbOrderRecord>(TbOrderRecord.class);
        util.exportExcel(response, list, "订单记录数据");
    }

    /**
     * 获取订单记录详细信息
     */
    @RequiresPermissions("prod:orderRecord:query")
    @GetMapping(value = "/orderRecord/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(tbOrderRecordService.selectTbOrderRecordByRecordId(recordId));
    }

    /**
     * 新增订单记录
     */
    @RequiresPermissions("prod:orderRecord:add")
    @Log(title = "订单记录", businessType = BusinessType.INSERT)
    @PostMapping("/orderRecord/add")
    public AjaxResult add(@RequestBody TbOrderRecord tbOrderRecord)
    {
        return toAjax(tbOrderRecordService.insertTbOrderRecord(tbOrderRecord));
    }

    /**
     * 修改订单记录
     */
    @RequiresPermissions("prod:orderRecord:edit")
    @Log(title = "订单记录", businessType = BusinessType.UPDATE)
    @PutMapping("/orderRecord/edit")
    public AjaxResult edit(@RequestBody TbOrderRecord tbOrderRecord)
    {
        return toAjax(tbOrderRecordService.updateTbOrderRecord(tbOrderRecord));
    }

    /**
     * 删除订单记录
     */
    @RequiresPermissions("prod:orderRecord:remove")
    @Log(title = "订单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/orderRecord/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(tbOrderRecordService.deleteTbOrderRecordByRecordIds(recordIds));
    }
}
